<%@ tag pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ attribute name="element" required="true" type="java.lang.Object" %>
<%@ attribute name="fieldNamePrefix" required="true" type="java.lang.String" %>
<%@taglib prefix="hp" tagdir="/WEB-INF/tags/cover" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<div class="form-group">
    <label class="col-md-2 control-label">文字:</label>
    <div class="col-md-10">
        <div class="input-icon">
            <input name="${fieldNamePrefix}text" type="text" class="form-control" value="${element.text}">
        </div>
    </div>
</div>
<div class="form-group">
    <label class="col-md-2 control-label">次要文字:</label>
    <div class="col-md-10">
        <div class="input-icon">
            <input name="${fieldNamePrefix}secondaryText" type="text" class="form-control" value="${element.secondaryText}">
        </div>
    </div>
</div>
<div class="form-group">
    <label class="col-md-2 control-label">图片:</label>
    <div class="col-md-10">
        <div class="input-icon">
            <img id="image" width="50%" src="${element.imgUrl}" alt="无图片" />
            <div class="btn btn-info logo_button">选择图片</div>
            <div class="btn btn-info del_logo_button">删除图片</div>
            <input type="file" style="display:none" class="logo_file" />
            <input name="${fieldNamePrefix}imgUrl" style="display:none" type="text" class="form-control" value="${element.imgUrl}">
        </div>
    </div>
</div>
<div class="form-group">
    <label class="col-md-2 control-label">链接:</label>
    <div class="col-md-10">
        <div class="input-icon">
            <input name="${fieldNamePrefix}link" type="text" class="form-control" value="${element.link}">
        </div>
    </div>
</div>
<div class="form-group">
    <label class="col-md-2 control-label">css样式:</label>
    <div class="col-md-10">
        <div class="input-icon">
            <input name="${fieldNamePrefix}styleClass" type="text" class="form-control" value="${element.styleClass}">
        </div>
    </div>
</div>
<div class="form-group">
    <label class="col-md-2 control-label">原价:</label>
    <div class="col-md-10">
        <div class="input-icon">
            <input name="${fieldNamePrefix}originPrice" type="number" step="1" class="form-control" value="${element.originPrice}">
        </div>
    </div>
</div>
<div class="form-group">
    <label class="col-md-2 control-label">售价:</label>
    <div class="col-md-10">
        <div class="input-icon">
            <input name="${fieldNamePrefix}salePrice" type="number" step="1" class="form-control" value="${element.salePrice}">
        </div>
    </div>
</div>
<div class="form-group">
    <label class="col-md-2 control-label">销售百分比:</label>
    <div class="col-md-10">
        <div class="input-icon">
            <input name="${fieldNamePrefix}soldPercent" type="number" step="1" class="form-control" value="${element.soldPercent}">
        </div>
    </div>
</div>
<div class="form-group">
    <label class="col-md-2 control-label">排序:</label>
    <div class="col-md-10">
        <div class="input-icon">
            <input name="${fieldNamePrefix}orderIndex" type="number" step="1" class="form-control" value="${element.orderIndex}">
        </div>
    </div>
</div>
<div class="form-group">
    <label class="col-md-2 control-label">生效时间(不填,则始终生效):</label>
    <div class="col-md-2">
        <div class="input-group bootstrap-timepicker timepicker">
            <input name="${fieldNamePrefix}startTime" value="<fmt:formatDate value="${element.startTime}" pattern="yyyy-MM-dd HH:mm:ss"/>" class="form-control timepicker" type="text"/>
        </div>
    </div>
    <div class="col-md-1 text-center">
        -
    </div>
    <div class="col-md-2">
        <input name="${fieldNamePrefix}endTime" value="<fmt:formatDate value="${element.endTime}" pattern="yyyy-MM-dd HH:mm:ss"/>" class="form-control timepicker" type="text"/>
    </div>
</div>
<div class="form-group">
    <label class="col-md-2 control-label">成员集合数据类型:</label>
    <div class="col-md-5">
        <div>
            <label class="line-height-1 blue">
                <input name="${fieldNamePrefix}elementsLoadType" value="STATIC" type="radio" class="ace element-data-policy"
                ${element.elementsLoadType != 'DYNAMIC' ? 'checked' :''}>
                <span class="lbl">静态数据</span>
            </label>
        </div>
        <div>
            <label class="line-height-1 blue">
                <input name="${fieldNamePrefix}elementsLoadType" value="DYNAMIC" type="radio" class="ace element-data-policy"
                ${element.elementsLoadType == 'DYNAMIC' ? 'checked' :''}>
                <span class="lbl">动态加载</span>
            </label>
        </div>
    </div>
</div>
<div class="static-elements-container" style="display: none">
    <div class="form-group">
        <label class="col-md-2 control-label">成员集合静态数据:</label>
        <div class="col-md-10">
            <table id="elements-table" class="table  table-bordered table-hover">
                <thead>
                <tr>
                    <th class="col-md-2">Index</th>
                    <th class="col-md-10">详情</th>
                </tr>
                </thead>

                <tbody>
                <hp:programStaticElements elements="${element.elements}" fieldNamePrefix="${fieldNamePrefix}"  />
                </tbody>
            </table>
            <button type="button" class="add-element-btn" data-field-name-prefix="${fieldNamePrefix}" onclick="addCoverTemplateElement(this)">
                <i class="ace-icon fa fa-plus"></i>
            </button>
        </div>
    </div>
</div>
<div class="dynamic-provider-container" style="display: none">
    <div class="form-group">
        <label class="col-md-2 control-label">成员集合数据动态提供者:</label>
        <div class="col-md-5">
            <c:forEach items="${elementDataProviders}" var="elementDataProvider">
                <div>
                    <label class="line-height-1 blue">
                        <input name="${fieldNamePrefix}methodExecutor" value="${elementDataProvider.identity}" type="radio" class="ace"
                            ${element.methodExecutor eq elementDataProvider.identity ? 'checked' :''}>
                        <span class="lbl">${elementDataProvider.description}</span>
                    </label>
                </div>
            </c:forEach>
        </div>
    </div>
    <div class="form-group">
        <label class="col-md-2 control-label">动态加载参数id:</label>
        <div class="col-md-5">
            <input name="${fieldNamePrefix}methodExecutorMethodParam.identity" type="text" placeholder="参数id"
                   class="form-control" value="${element.methodExecutorMethodParam.identity}">
        </div>
    </div>
    <div class="form-group">
        <label class="col-md-2 control-label">动态加载数据ids，以","号分割:</label>
        <div class="col-md-5">
            <input name="${fieldNamePrefix}methodExecutorMethodParam.stringDataIds" type="text" placeholder="数据Ids"
                   class="form-control" value="${element.methodExecutorMethodParam.stringIds}">
        </div>
    </div>

</div>